<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="../../src/css/common/reset.css">
    <script src="../../src/lib/jquery.min.js"></script>
</head>
<body>

<div onclick="">
    <div style="width: 100%;height:50vh;background-color: #1b6d85">

        <iframe id="frame" src="" frameborder="0">

        </iframe>

        <button id="test" >点击</button>
    </div>


</div>

<script>
    document.domain = '192.168.3.77';
    $(function(){

        function posts(origin){
            //推送数据
            origin.postMessage('8888',"*")
        }

        let frameObj = $("#frame");
            frameObj.on('load',function(){
                console.log('load');
                console.log(frameObj[0])
                frameObj[0].contentWindow.preLoadVideo();
                //posts(frameObj[0].contentWindow);
            })

        $("#test").on('click',function(){
            frameObj.attr('src','http://192.168.3.77:8080/src/view/index.html');
        })

    })




    window.addEventListener('message',function(e){
        console.log('已监听到子窗口事件: ',e);
        if(e.origin == 'http://me.api.com'){
            //to do something
            console.log(e.data)
        }
    },false);

</script>
</body>
</html>